<template>
	<view>
		<view class="haveData">
			<view class="title">
				预约成功
			</view>
			<view class="contentBox">
				<view class="content">
					疫苗名称：新冠病毒疫苗
				</view>
				<view class="content">
					预约时间：{{vaccine.time}}
				</view>
				<view class="content">
					预约地点：{{vaccine.address}}
				</view>
				<view class="content">
					疫苗厂商：{{vaccine.produrer}}
				</view>
				<view class="content">
					接种人：{{vaccine.username}}
				</view>
			</view>
			<view class="qrcode">
				<tki-qrcode ref="qrcode" :val="val" :size="size" :background="background" :foreground="foreground" 
				:pdground="pdground"  :onval="onval" :loadMake="loadMake" @result="qrR">
					
				</tki-qrcode>
			</view>
			<view class="btBox">
				<u-button style="width: 40%;" type="danger" @click="modelShow=true">取消预约</u-button>
				<u-button style="width: 40%;" type="primary" @click="toIndex">返回首页</u-button>
			</view>
			<u-toast ref="uToast" />
			<u-modal v-model="modelShow" :content="ModelContent" @confirm="cancelYuyue" :show-cancel-button="true" @cancel="modelShow=false"></u-modal>
		</view>
	</view>
</template>

<script>
	import tkiQrcode from '../../components/uni-app-qrcode-master/components/tki-qrcode/tki-qrcode.vue'
	export default {
		components:{
			tkiQrcode
		},
		data() {
			return {
				vaccine:{},
				val:'',
				size:200,
				background:"#fff",
				foreground:"#089256",
				pdground:"#089256",
				onval:true,
				loadMake:true,
				ModelContent:'您确定要取消预约吗',
				modelShow:false
			};
		},
		onLoad() {
			uni.getStorage({
				key:'vaccine',
				success:res=>{
					this.val = res.data.name + " " + res.data.address + " " + res.data.time + " " + res.data.produrer + " " + res.data.username
					this.vaccine = res.data
				},
				fail:err=>{
					uni.showToast({
						title:"获取预约数据失败",
						icon:"none"
					})
				}
			})
		},
		methods:{
			toIndex(){
				uni.switchTab({
					url:'/pages/index/index'
				})
			},
			cancelYuyue(){
				uni.removeStorage({
					key:'vaccine',
					success:res=>{
						this.$refs.uToast.show({
							title: '预约取消成功',
							type: 'success',
							url: '/pages/yimiaoyuyue/yimiaoyuyue'
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
.haveData{
	width: 100%;
	text-align: center;
	.title{
		color: #089256;
		font-size: 100rpx;
		margin: 30rpx 0;
	}
	.contentBox{
		.content{
			
			margin: 30rpx;
		}
	}
}
.btBox{
	display: flex;
	justify-content: space-between;
	align-items: center;
	position: fixed;
	bottom: 20rpx;
	width: 100%;
}
</style>
